package com.blog.blogservice.infra.exception;

/**
 * @author guanglin.ma
 * @date 2023-12-04 14:46
 */
//@ResponseBody
//扫描包路径
//@ControllerAdvice(value = {"com.blog.blogservice.api.controller"})
//public class ExceptionControllerAdvice {

//    @ExceptionHandler(value = MethodArgumentNotValidException.class)
//    public BaseResponse handlerValidExecption(MethodArgumentNotValidException methodArgumentNotValidException) {
//        Map map = new HashMap<>();
//        for (FieldError fieldError : methodArgumentNotValidException.getBindingResult().getFieldErrors()) {
//            map.put(fieldError.getField(), fieldError.getDefaultMessage());
//        }
//        return BaseResponse.error("10001", "校验错误");
//    }

//    @ExceptionHandler(value = Exception.class)
//    public BaseResponse handlerExecption(Exception exception) {
//        return BaseResponse.error("4000", exception.toString());
//    }

//    @ExceptionHandler(value = Throwable.class)
//    public R handlerThrowableExecption(Throwable throwable) {
//        return R.error(400, "未知异常信息").put("data", throwable.getMessage());
//    }
//}
